Skip to content

PhpFileCleaner: Use strcspn instead of regex for fast-skip in clean()#5600

Merged
staabm merged 2 commits intophpstan:2.1.xfrom
staabm:fast-clean
May 5, 2026
Merged

PhpFileCleaner: Use strcspn instead of regex for fast-skip in clean()#5600
staabm merged 2 commits intophpstan:2.1.xfrom
staabm:fast-clean

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented May 5, 2026

applies the upstream performance optimizations from

Jordi reported a 20-25% perf increase regarding file-cleaning with this changes (see comments in referenced PRs).
I was not able to replicate the demonstrated perf benefit of the upstream PRs in a PHPStan use-case.
(I remember though that I have seen blackfire profiles in the past, which had a bottleneck on PhpFileCleaner regex-matching)
Still I think its useful to keep our copied-in code as close to the upstream as possible.

@staabm staabm merged commit c28d352 into phpstan:2.1.x May 5, 2026
944 of 945 checks passed
@staabm staabm deleted the fast-clean branch May 5, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants